package com.gengzp.rpc.enums;

/**
 * @ClassName RpcServiceRegisterCenterEnum
 * @Description rpc框架服务注册中心枚举
 * @Author gengzp
 * @Date 2025/8/20 17:20
 */
public enum RpcServiceRegisterCenterEnum {

    /**
     * redis
     */
    REDIS("Redis", "Redis"),

    /**
     * nacos v1版本
     */
    NACOS_V1("NACOS_V1", "NacosV1"),

    /**
     * nacos v2版本
     */
    NACOS_V2("NACOS_V2", "NacosV2"),
    ;

    // 配置中的名称
    private final String name;

    // 配置中的bean名称
    private final String beanName;

    RpcServiceRegisterCenterEnum(String name, String beanName) {
        this.name = name;
        this.beanName = beanName;
    }

    public String getName() {
        return name;
    }

    public static RpcServiceRegisterCenterEnum getByName(String name) {
        for (RpcServiceRegisterCenterEnum value : values()) {
            if (value.name.equals(name)) {
                return value;
            }
        }
        return null;
    }

    public static String getBeanNameByName(String name) {
        for (RpcServiceRegisterCenterEnum value : values()) {
            if (value.name.equals(name)) {
                return value.beanName;
            }
        }
        return null;
    }

}
